﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Xml;

namespace Sun.Mvc.Framework
{
    public class XmlHelper
    {
        private string Path = null;
        public XmlHelper(string _path)
        {
            Path = _path;
        }

        /// <summary>
        /// 根据错误编号找到错误信息
        /// </summary>
        /// <param name="code">错误编号</param>
        /// <returns></returns>
        public string GetMessage(int code)
        {
            using (XmlReader reader = XmlReader.Create(Path))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(reader);

                return doc.SelectSingleNode("response/message[@code="+ code +"]").InnerText;
            }
        }
    }
}
